/**
\author Zachary Wartell - Copyright 2006: All rights reserved.
\brief exercise the List class
*/
#include "List.h"
#include <iostream>
#include <vld.h>

using namespace std;

/**
\brief convert n.name to upper case
*/
void upCase(List::Node& n)
    {
    int i;
    for(i=0;i<List::Node::NAME_SIZE;i++)
	if (isalpha(n.name[i]) && islower(n.name[i])) 
	    n.name[i] = (char)toupper(n.name[i]);
    }

/**
\brief print hi to Node 'n'
*/
void sayHello(List::Node& n)
    {
    cout << "Hi " << n.name << endl;
    }

/**
\brief print bye to Node 'n'
*/
void sayGoodbye(List::Node& n)
    {
    cout << "Bye " << n.name << endl;
    }

int main (char** argv, int argc)
    {
    List list;
    /** add some nodes */
    list.add("First");
    list.add("Second");
    list.add("Third");

    /** exercise functions */
    list.print();    
    list.traverse(sayHello);
    list.traverse(upCase);
    list.traverse(sayGoodbye);

    return 0;
    }